<?php

use yii\db\Migration;

class m171108_024351_alter_arrangement extends Migration
{
    private function createDbs(){
        $dbs = [];
        $dbs_info =\Yii::$app->params['db'];
        foreach($dbs_info as $k=>$v){
            $dbs[$k] = \Yii::createObject($v);
        }
        return $dbs;
    }

    public function safeUp()
    {
        $dbs = $this->createDbs();
        foreach ($dbs as $v) {
            $this->db = $v;
            $this->alterColumn('{{%arrangement}}','teacher_id',$this->string(50).' default null comment \'老师id逗号隔开\'');
            $this->addColumn('{{%arrangement}}','room_type',$this->smallInteger(1)->defaultValue(0)->comment('教室类型 （0 正常教室，1 共享教室）'));
        }
    }

    public function safeDown()
    {
        $dbs = $this->createDbs();
        foreach ($dbs as $v) {
            $this->db = $v;
            $this->dropTable('{{%arrangement}}');
        }
    }
}
